(function(){
	
	Ext.define('GridStore',{
		extend:'Ext.data.Store',
		autoLoad: true,
		fields: [
			{name:'id'},
			{name:'goodsName'},
			{name:'goodsStock'},
			{name:'goodsPrice'},
			{name:'goodsUnit'},
			{name:'stockTotalPrice'},
			{name:'stockGoodsNum'},
			{name:'deliveryTotalPrice'},
			{name:'deliveryGoodsNum'},
			{name:'netIncome'},
			{name:'stockSurplus'},
			{name:'createTime'},
			{name:'isUse'}
		],
		pageSize:20,
	    proxy: {
	        type: 'ajax',
	        url: '/goodsStock/list.do',
	        reader: {
	            type: 'json',
	            root: 'objectList',
	            totalProperty:'allCount'
	        }
	    }
	});
	
	Ext.define('NetShopping.goodsStock.GoodsStockGrid',{
		extend:'AppView.base.BaseGrid',
		alias:'widget.goodsstockgrid',
		btConfig:{//默认按钮
			add:false,
			edit:false,
			del:false,
			refresh:true
		},
		columns: [
	        { text: '商品名称',  dataIndex: 'goodsName' ,flex: 1 },
	        { text: '剩余库存', dataIndex: 'stockSurplus', flex: 1 },
	        { text: '进货数量', dataIndex: 'stockGoodsNum', flex: 1 },
	        { text: '出货数量', dataIndex: 'deliveryGoodsNum', flex: 1 },
	        { text: '进货总价(元)', dataIndex: 'stockTotalPrice', flex: 1 },
	        { text: '出货总价(元)', dataIndex: 'deliveryTotalPrice', flex: 1 },
	        { text: '净利润(元)', dataIndex: 'netIncome', flex: 1 }
	    ],
	    dockedItems: [{
	        xtype: 'toolbar',
	        dock: 'top',
	        items: [{
				xtype:'textfield',
				margin:'0 0 0 5',
				fieldLabel:'商品名称',
				labelWidth:60,
				name:'goodsName'
		    },{
                text: '检索',
                icon: 'resources/button/search.png',
                handler:function(){
                	var grid = this.up('grid');
                	grid.getStore().getProxy().extraParams.goodsName = grid.down('[name=goodsName]').getValue();
                	grid.getStore().loadPage(1);
                }
            },
            {
                text: '重置',
                icon: 'resources/button/set.png',
                handler:function(){
                	this.up('toolbar').down('[name=goodsName]').setValue('');
                }
            }]
	    }],
//	    gridTbar:[
//			{
//				xtype: 'button',
//				icon:'resources/button/set.png',
//				text: '加入购物车'
//			}
//		],
	    editWin:'NetShopping.goodsStock.GoodsStockWin',
	    gridStore:'GridStore',
	    moduleUrl:'/goodsStock',
	    initComponent:function(){
			this.callParent();
	    }
	})
})()

